﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>修改密码</title>
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />
    <script src="~/Content/jquery/jquery.min.js"></script>
    <script src="~/Content/jquery/jquery.md5.js"></script>
    <script src="~/Content/layui/layui.js"></script>
    <script src="~/Content/framework/js/global.js"></script>
</head>
<body>
    <form id="modifyPwdForm" class="layui-form layui-form-pane" style="margin: 30px;">
        <div class="layui-form-item">
            <label class="layui-form-label">旧密码</label>
            <div class="layui-input-block">
                <input type="password" name="oldPassword" lay-verify="password" autocomplete="off" placeholder="请输入旧密码" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">新密码</label>
            <div class="layui-input-block">
                <input type="password" name="newPassword" lay-verify="password" autocomplete="off" placeholder="请输入新密码" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-block">
                <input type="password" name="confirmPassword" lay-verify="password" autocomplete="off" placeholder="请确认新密码" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-filter="savePwd" lay-submit>保存</button>
                <button id="btnReset" class="layui-btn layui-btn-danger" type="reset">重置</button>
            </div>
        </div>
    </form>
</body>
</html>

<script type="text/javascript">
    layui.use(['form'], function () {
        var form = layui.form();
        form.verify({
            password: [/^[A-Za-z0-9._-]{6,16}$/, '密码必须6到16位，不能包含特殊字符。']
        });
        form.on('submit(savePwd)', function (data) {
            data.field.oldPassword = $.md5(data.field.oldPassword);
            data.field.newPassword = $.md5(data.field.newPassword);
            data.field.confirmPassword = $.md5(data.field.confirmPassword);
            $.formSubmit({
                url: "/Account/ModifyPwd",
                data: data.field,
                close: false
            });
            return false;
        });
    });
</script>
